home *** CD-ROM | disk | FTP | other *** search
/ Macromedia Multimedia Showcase 6.0 / Macromedia Multimedia Showcase v6.0 WIN-MAC (XMSH60CD)(Macromedia, Inc.)(1996).iso / pc / demosoft / xres / data.z / GENERIC.PS < prev    next >
Text File  |  1995-07-28  |  6KB  |  223 lines

  1. %!
  2. %%VMusage: 5132 5132
  3. %%VMlocation: global
  4. %%
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6. %%                                    %%
  7. %% This file implements the Generic category resource.            %%
  8. %%                                    %%
  9. %% The Generic implementation stores instances of the resource in   %%
  10. %% local VM in a dictionary with the category name in Resources in  %%
  11. %% userdict.  Global instances are held in Instances in the        %%
  12. %% category implementation dictionary.  It looks for disc files in  %%
  13. %% %resources%category.                            %%
  14. %%                                    %%
  15. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  16.  
  17. <<
  18.   /Category /Generic
  19.  
  20. %%
  21. %% ResourceFileName builds a filename of the form %resource%category/instance
  22. %%
  23.   /ResourceFileName {
  24.     dup 0 (%resource%) putinterval
  25.     dup 10 1 index length 10 sub getinterval
  26.     Category exch cvs
  27.     length 10 add
  28.     2 copy 16#2f put 1 add
  29.     2 copy 1 index length 1 index sub getinterval
  30.     3 index exch cvs length add 0 exch getinterval exch pop
  31.   } bind
  32.  
  33.   /FindResource {
  34.     currentglobal not {
  35.       LocalInstances 1 index known {
  36.         LocalInstances exch get false
  37.       } {
  38.         true
  39.       } ifelse
  40.     } {
  41.       true
  42.     } ifelse
  43.     {
  44.       Instances 1 index known not {
  45.         dup 256 string ResourceFileName
  46.         dup status {
  47.           pop pop pop pop 
  48.           currentglobal exch true setglobal
  49.           mark exch 20 dict begin {run} stopped end cleartomark
  50.           setglobal
  51.         } {
  52.           pop
  53.         } ifelse
  54.       } if
  55.       Instances 1 index known {
  56.         Instances exch get
  57.       } {
  58.         LocalInstances 1 index known {
  59.           LocalInstances exch get
  60.         } {
  61.           /findresource
  62.           errordict /undefinedresource get exec
  63.         } ifelse
  64.       } ifelse
  65.     } if
  66.   } bind
  67.  
  68.   /DefineResource {
  69.     currentglobal {
  70.       LocalInstances 2 index known {
  71.         LocalInstances 2 index undef
  72.       } if
  73.       Instances 3 -1 roll 2 index put
  74.     } {
  75.       LocalInstances 3 -1 roll 2 index put
  76.     } ifelse
  77.   } bind
  78.  
  79.   /UndefineResource {
  80.     currentglobal {
  81.       LocalInstances 1 index known {
  82.         LocalInstances 1 index undef
  83.       } if
  84.       Instances 1 index known {
  85.         Instances 1 index undef
  86.       } if
  87.       pop
  88.     } {
  89.       LocalInstances 1 index known {
  90.         LocalInstances 1 index undef
  91.       } if
  92.       pop
  93.     } ifelse
  94.   } bind
  95.  
  96.   /ResourceStatus {
  97.     currentglobal {
  98.       false
  99.     } {
  100.       LocalInstances 1 index known
  101.     } ifelse
  102.     Instances 2 index known or {
  103.       pop 0 -1 true
  104.     } {
  105.       256 string ResourceFileName
  106.       dup status {
  107.         pop pop pop pop
  108.         (r) file 256 string readstring pop  %% Is this good enough?
  109.         (%%VMusage:) search {
  110.           pop pop 2 exch
  111.           token pop exch token pop exch pop
  112.       2 copy lt {exch} if pop
  113.           true
  114.         } {
  115.           pop 2 -1 true
  116.         } ifelse
  117.       } {
  118.         pop false
  119.       } ifelse
  120.     } ifelse
  121.   } bind
  122.  
  123.   /ResourceForAll {
  124.     currentdict end
  125.     10 dict begin
  126.     /cat exch def
  127.     userdict /##_RFA_TEMP_## currentdict put
  128.     /scratch exch def
  129.     /proc exch def
  130.     /template exch def
  131.     /done false def
  132.     currentglobal not {
  133.       cat begin LocalInstances end {
  134.         pop scratch cvs dup template stringmatch {
  135.           /proc load
  136.           end stopped
  137.           ##_RFA_TEMP_## begin
  138.           {
  139.             $error /errorname get dup /invalidexit eq {
  140.               pop /done true def exit
  141.             } {
  142.               $error /command get exch
  143.               errordict exch get exec
  144.             } ifelse
  145.           } if
  146.         } {
  147.           pop
  148.         } ifelse
  149.       } forall
  150.     } if
  151.     done not {
  152.       cat /Instances get {
  153.         pop
  154.         cat begin LocalInstances end 1 index known not
  155.         exch scratch cvs dup template stringmatch 3 -1 roll and {
  156.           /proc load
  157.           end stopped
  158.           ##_RFA_TEMP_## begin
  159.           {
  160.             $error /errorname get dup /invalidexit eq {
  161.               pop /done true def exit
  162.             } {
  163.               $error /command get exch
  164.               errordict exch get exec
  165.             } ifelse
  166.           } if
  167.         } {
  168.           pop
  169.         } ifelse
  170.       } forall
  171.     } if
  172.     done not {
  173.       (*) 256 string cat begin ResourceFileName end {
  174.         (/) search {
  175.           pop pop dup template stringmatch {
  176.             dup cvn
  177.             cat begin LocalInstances end 1 index known
  178.             cat /Instances get 3 -1 roll known or not {
  179.               scratch cvs
  180.               /proc load
  181.               end stopped
  182.               ##_RFA_TEMP_## begin
  183.               {
  184.                 $error /errorname get dup /invalidexit eq {
  185.                   pop /done true def exit
  186.                 } {
  187.                   $error /command get exch
  188.                   errordict exch get exec
  189.                 } ifelse
  190.               } if
  191.             } {
  192.               pop
  193.             } ifelse
  194.           } {
  195.             pop
  196.           } ifelse
  197.         } {
  198.           pop
  199.         } ifelse
  200.       } 256 string filenameforall
  201.     } if
  202.     end
  203.     ##_RFA_TEMP_## /cat get begin
  204.     userdict /##_RFA_TEMP_## undef
  205.   } bind
  206.  
  207.   /LocalInstances {
  208.     userdict /Resources known not {
  209.       userdict /Resources
  210.       currentglobal false setglobal 1 dict exch setglobal
  211.       put
  212.     } if
  213.     userdict /Resources get dup Category known not {
  214.       dup Category 1 dict put
  215.     } if
  216.     Category get
  217.   } bind
  218.  
  219. >>
  220.  
  221. dup /Category get exch /Category defineresource pop
  222.  
  223.